﻿//新增周计划
var fnAddWeekPlan = function () {
    parent.addTabs('新增周计划', '../TR/WeekPlan.aspx?r=' + Math.random() + '&entity=TrWeekPlan&CLOSE=新增周计划&WPID=');
    parent.NeedRefreshPage = this;
    //    document.getElementById("EditUIWindow").src = "../TR/WeekPlan.aspx?r=" + Math.random() + "&entity=TrWeekPlan&WPID=";
    //    YAHOO.example.container.dialog1.show();
}
//编辑周计划
var fnEditWeekPlan = function () {
    var recordID = myDataTable.getSelectedRows()[0];
    record = myDataTable.getRecord(recordID);
    if (record == null) {
        alert("请选择一条记录");
        return;
    }
    parent.addTabs('编辑' + record.getData("UName") + '周计划', '../TR/WeekPlan.aspx?r=' + Math.random() + '&entity=TrWeekPlan&CLOSE=编辑' + record.getData("UName") + '周计划&WPID=' + record.getData(const_entityID));
    parent.NeedRefreshPage = this;
    //    document.getElementById("EditUIWindow").src = "../TR/WeekPlan.aspx?r=" + Math.random() + "&entity=TrWeekPlan&WPID=" + record.getData(const_entityID);
    //    YAHOO.example.container.dialog1.show();
}
//新增周结果
var fnAddWeekResult = function () {
    document.getElementById("EditUIWindow").src = "../TR/WeekResult.aspx?r=" + Math.random() + "&entity=TrWeekPlan&WPID=";
    YAHOO.example.container.dialog1.show();
    parent.NeedRefreshPage = this;
}
//编辑周结果
var fnEditWeekResult = function () {
    var recordID = myDataTable.getSelectedRows()[0];
    record = myDataTable.getRecord(recordID);
    if (record == null) {
        alert("请选择一条记录");
        return;
    }
    parent.addTabs(record.getData("UName") + '周结果', '../TR/WeekResult.aspx?r=' + Math.random() + '&entity=TrWeekPlan&CLOSE=' + record.getData("UName") + '周结果&WPID=' + record.getData(const_entityID));
    parent.NeedRefreshPage = this;
    //    document.getElementById("EditUIWindow").src = "../TR/WeekResult.aspx?r=" + Math.random() + "&entity=TrWeekPlan&WPID=" + record.getData(const_entityID);
    //    YAHOO.example.container.dialog1.show();
}

//点评
var fnCheck = function () {
    var recordID = myDataTable.getSelectedRows()[0];
    record = myDataTable.getRecord(recordID);
    if (record == null) {
        alert("请选择一条记录");
        return;
    }
    document.getElementById("EditUIWindow").src = "../TR/WorkCheck.aspx?r=" + Math.random() + "&entity=TrWeekPlan&TYPE=W&WPID=" + record.getData(const_entityID);
    YAHOO.example.container.dialog1.show();
}

var fnchakan = function () {
    CustomDbClick();
}
//双击事件
function CustomDbClick() {
    var recordID = myDataTable.getSelectedRows()[0];
    record = myDataTable.getRecord(recordID);
    if (record == null) {
        alert("请选择一条记录");
        return;
    }
    parent.$("#tabs").tabs('close', record.getData("UName") + '周计划周结果');
    parent.addTabs(record.getData("UName") + '周计划周结果', '../TR/WeekResult.aspx?r=' + Math.random() + '&entity=TrWeekPlan&TYPE=LOOK&WPID=' + record.getData(const_entityID));
}
if (typeof ($) != "undefined") {
    $(document).ready(function () {
        try {
            var varStr = $("form").attr("action");
            var arr = varStr.split('&');
            var arr2 = new Array();
            for (var i = 1; i < arr.length; i++) {
                arr2.push(arr[i]);
            }
            var varCheck = arr2[0].substring(7, arr2[0].length);
            if (varCheck == "check") {
                $("#fieldForm").wrap("<span id='wrap'></span>");
                var obj = document.getElementById("wrap");
                obj.onmouseover = function () {
                    obj.setCapture();
                }
                obj.onmouseout = function () {
                    obj.releaseCapture();
                }
                obj.onfocus = function () {
                    obj.blur();
                }
                obj.onbeforeactivate = function () {
                    return false;
                }
            }
        } catch (Error) { }
    })
}

var formatText = function (elCell, oRecord, oColumn, sData) {
    sData.replace("[BR]", "");
    if (sData.length > 30) {
        elCell.innerHTML = sData.substring(0, 30) + "..." + "<a href='javascript:CustomDbClick()'>详细</a>";
    }
    else {
        elCell.innerHTML = sData;
    }
};